<template>
	<cl-select-table
		v-model="value"
		:title="t('选择订单商品')"
		:service="service.order.goods"
		:columns="columns"
		:multiple="multiple"
		:dict="{ text: 'goodsname' }"
		pickerType="text"
	/>
</template>

<script setup lang="ts">
defineOptions({
	name: "order-goods-select",
});

import { useCool } from "/@/cool";
import { useI18n } from "vue-i18n";
import { CrudProps } from "/#/crud";
import { ref, useModel } from "vue";

const props = defineProps({
	...CrudProps,
	modelValue: null,
	multiple: Boolean,
});

const { service } = useCool();
const { t } = useI18n();

const value = useModel(props, "modelValue");

const columns = ref([
	{ label: t("订单ID"), prop: "orderId", minWidth: 140 },
	{ label: t("商品名称"), prop: "goodsName", minWidth: 140 },
	{
		label: t("购买数量"),
		prop: "quantity",
		minWidth: 140,
		sortable: "custom",
	},
	{ label: t("单价"), prop: "price", minWidth: 140, sortable: "custom" },
	{ label: t("规格参数"), prop: "specifications", minWidth: 140 },
]);
</script>
